from langchain.chains.conversation.base import ConversationChain
from langchain.memory import ConversationSummaryMemory
from langchain_openai import OpenAI

# 大模型
llm = OpenAI(
    api_key="sk-VowKQBUMIkSND8WScNJtDLqf3FyqWHQ43LMVUXH1m6GZaopA",
    base_url="https://ai.nengyongai.cn/v1",
    temperature=0
)


def test1():
    #
    memory = ConversationSummaryMemory(llm=llm)
    # chain
    chain = ConversationChain(llm=llm, memory=memory)

    #
    replay = chain.run('你好，可以告诉我什么是机器学习吗？中文')
    print(replay)
    replay = chain.run('深度学习和机器学习有什么区别 中文')
    print(replay)
    
    print(memory.load_memory_variables({}))
